<template>
  <el-table
    :data="arr"
    style="width: 100%"
    @selection-change="handleSelectionChange"
  >
    <el-table-column type="selection" width="55"> </el-table-column>>

    <el-table-column label="姓名" width="100">
      <template slot-scope="scope">
        <span>{{ scope.row.name }}</span>
      </template>
    </el-table-column>
    <el-table-column label="就诊卡号" width="100">
      <template slot-scope="scope">
        <span>{{ scope.row.jiuka }}</span>
      </template>
    </el-table-column>

    <el-table-column label="身份证号" width="180">
      <template slot-scope="scope">
        <span>{{ scope.row.card }}</span>
      </template>
    </el-table-column>

    <el-table-column label="手机号码" width="130">
      <template slot-scope="scope">
        <span>{{ scope.row.number }}</span>
      </template>
    </el-table-column>

    <el-table-column label="科室" width="100">
      <template slot-scope="scope">
        <span>{{ scope.row.dwork }}</span>
      </template>
    </el-table-column>

    <el-table-column label="检测费" width="100">
      <template slot-scope="scope">
        <span>{{ scope.row.testfee }}</span>
      </template>
    </el-table-column>

    <el-table-column label="状态" width="100">
      <template slot-scope="scope">
        <span style="color: green">{{ scope.row.state }}</span>
      </template>
    </el-table-column>

    <el-table-column label="就诊日期" width="100">
      <template slot-scope="scope">
        <span>{{ scope.row.date }}</span>
      </template>
    </el-table-column>

    <el-table-column label="候诊时间" width="100">
      <template slot-scope="scope">
        <span>{{ scope.row.date }}</span>
      </template>
    </el-table-column>

    <el-table-column label="预约时间" width="100">
      <template slot-scope="scope">
        <span>{{ scope.row.date }}</span>
      </template>
    </el-table-column>

    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini" @click="handleEdit(scope.row)"
          >编辑</el-button
        >
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.row.card)"
          >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { delteById, batchDelete } from "../../../api/na";
import eventBus from "../../../utils/busEvent";
export default {
  props: ["arr"],
  data() {
    return {
      tableData: [
        {
          name: "王小虎",
          jiuka: "838764",
          card: "3722087488939883939",
          number: "17098530203",
          dwork: "口腔",
          testfee: "30",
          state: "良好",
          date: "2016-05-02",
        },
      ],
      multipleSelection: [],
    };
  },
  mounted() {
    eventBus.$on("batchtranfer", this.bathchDeletehans);
  },

  methods: {
    handleEdit(row) {
     this.$emit('openDialod',row)
    },
    handleDelete(card) {
      console.log(card);
      delteById({ jiuka: card }).then((res) => {
        console.log(res);
        if (res.code == 200) {
          this.$emit("resettale");
        }
      });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    bathchDeletehans() {
      console.log("调用");
      var ids = [];
      this.multipleSelection.forEach((item) => {
        ids += item.card + ",";
      });
      console.log("ids", ids);
      batchDelete({ ids: ids }).then((res) => {
        console.log(res);
         if (res.code == 200) {
          this.$emit("resettale");
        }
      });
    },
  },
};
</script>
<style scoped lang="less">
/deep/.el-table__header-wrapper {
  overflow: hidden;
  height: 50px;
}
</style>